package exist;

public class AdminProxy implements exist.Admin {
  private String _endpoint = null;
  private exist.Admin admin = null;
  
  public AdminProxy() {
    _initAdminProxy();
  }
  
  public AdminProxy(String endpoint) {
    _endpoint = endpoint;
    _initAdminProxy();
  }
  
  private void _initAdminProxy() {
    try {
      admin = (new exist.AdminServiceLocator()).getAdmin();
      if (admin != null) {
        if (_endpoint != null)
          ((javax.xml.rpc.Stub)admin)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        else
          _endpoint = (String)((javax.xml.rpc.Stub)admin)._getProperty("javax.xml.rpc.service.endpoint.address");
      }
      
    }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  
  public String getEndpoint() {
    return _endpoint;
  }
  
  public void setEndpoint(String endpoint) {
    _endpoint = endpoint;
    if (admin != null)
      ((javax.xml.rpc.Stub)admin)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    
  }
  
  public exist.Admin getAdmin() {
    if (admin == null)
      _initAdminProxy();
    return admin;
  }
  
  public void store(java.lang.String sessionId, byte[] data, java.lang.String encoding, java.lang.String path, boolean replace) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.store(sessionId, data, encoding, path, replace);
  }
  
  public java.lang.String connect(java.lang.String userId, java.lang.String password) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.connect(userId, password);
  }
  
  public void disconnect(java.lang.String sessionId) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.disconnect(sessionId);
  }
  
  public boolean removeCollection(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.removeCollection(sessionId, path);
  }
  
  public boolean removeDocument(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.removeDocument(sessionId, path);
  }
  
  public boolean createCollection(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.createCollection(sessionId, path);
  }
  
  public int xupdate(java.lang.String sessionId, java.lang.String collectionName, java.lang.String xupdate) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.xupdate(sessionId, collectionName, xupdate);
  }
  
  public int xupdateResource(java.lang.String sessionId, java.lang.String documentName, java.lang.String xupdate) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.xupdateResource(sessionId, documentName, xupdate);
  }
  
  public byte[] getBinaryResource(java.lang.String sessionId, java.lang.String name) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getBinaryResource(sessionId, name);
  }
  
  public exist.CollectionDesc getCollectionDesc(java.lang.String sessionId, java.lang.String collectionName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getCollectionDesc(sessionId, collectionName);
  }
  
  public void setPermissions(java.lang.String sessionId, java.lang.String resource, java.lang.String owner, java.lang.String ownerGroup, int permissions) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.setPermissions(sessionId, resource, owner, ownerGroup, permissions);
  }
  
  public void copyResource(java.lang.String sessionId, java.lang.String docPath, java.lang.String destinationPath, java.lang.String newName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.copyResource(sessionId, docPath, destinationPath, newName);
  }
  
  public void copyCollection(java.lang.String sessionId, java.lang.String collectionPath, java.lang.String destinationPath, java.lang.String newName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.copyCollection(sessionId, collectionPath, destinationPath, newName);
  }
  
  public void setUser(java.lang.String sessionId, java.lang.String name, java.lang.String password, java.lang.String[] groups, java.lang.String home) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.setUser(sessionId, name, password, groups, home);
  }
  
  public exist.UserDesc getUser(java.lang.String sessionId, java.lang.String user) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getUser(sessionId, user);
  }
  
  public void removeUser(java.lang.String sessionId, java.lang.String name) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.removeUser(sessionId, name);
  }
  
  public exist.UserDesc[] getUsers(java.lang.String sessionId) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getUsers(sessionId);
  }
  
  public java.lang.String[] getGroups(java.lang.String sessionId) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getGroups(sessionId);
  }
  
  public void moveCollection(java.lang.String sessionId, java.lang.String collectionPath, java.lang.String destinationPath, java.lang.String newName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.moveCollection(sessionId, collectionPath, destinationPath, newName);
  }
  
  public void moveResource(java.lang.String sessionId, java.lang.String docPath, java.lang.String destinationPath, java.lang.String newName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.moveResource(sessionId, docPath, destinationPath, newName);
  }
  
  public void lockResource(java.lang.String sessionId, java.lang.String path, java.lang.String userName) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.lockResource(sessionId, path, userName);
  }
  
  public void unlockResource(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.unlockResource(sessionId, path);
  }
  
  public java.lang.String hasUserLock(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.hasUserLock(sessionId, path);
  }
  
  public exist.Permissions getPermissions(java.lang.String sessionId, java.lang.String resource) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getPermissions(sessionId, resource);
  }
  
  public exist.EntityPermissions[] listCollectionPermissions(java.lang.String sessionId, java.lang.String name) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.listCollectionPermissions(sessionId, name);
  }
  
  public exist.EntityPermissions[] listDocumentPermissions(java.lang.String sessionId, java.lang.String name) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.listDocumentPermissions(sessionId, name);
  }
  
  public exist.IndexedElement[] getIndexedElements(java.lang.String sessionId, java.lang.String collectionName, boolean inclusive) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    return admin.getIndexedElements(sessionId, collectionName, inclusive);
  }
  
  public void storeBinary(java.lang.String sessionId, byte[] data, java.lang.String path, java.lang.String mimeType, boolean replace) throws java.rmi.RemoteException{
    if (admin == null)
      _initAdminProxy();
    admin.storeBinary(sessionId, data, path, mimeType, replace);
  }
  
  
}